package com.tandashi.springbootstudy01.component;

import com.tandashi.springbootstudy01.security.shiro.StudyPrincipal;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CommonComponent {
    public StudyPrincipal getStudyPrincipal() {
        Object obj = SecurityUtils.getSubject().getPrincipal();
        if (obj instanceof StudyPrincipal) {
            return (StudyPrincipal) obj;
        } else {
            return null;
        }
    }
}
